package com.infoland.afanmall.model.pinTuan.adapter;

import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatImageView;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.LinearLayoutCompat;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.blankj.utilcode.util.SizeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.infoland.afanmall.R;
import com.infoland.afanmall.base.util.LogKit;
import com.infoland.afanmall.base.util.ToolsKit;
import com.infoland.afanmall.model.pinTuan.entity.PinTEntity;
import com.infoland.afanmall.model.zhongChou.entity.ZhongChouResponse;

import java.math.BigDecimal;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @author 王永吉
 * @date 2018/7/12 9:43
 * 拼团首页Adapter
 */
public class PinTAdapter extends BaseQuickAdapter<PinTEntity, BaseViewHolder> {

    public PinTAdapter(int layoutResId, @Nullable List<PinTEntity> data) {
        super(R.layout.pin_tuan_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PinTEntity item) {
        ButterKnife.bind(this, helper.itemView);
        if ((helper.getAdapterPosition() + 1) == getData().size() && getData().size() > 0) {
            ToolsKit.addMarginDp(helper.itemView, 0, 0, 0, 50);
        }
    }

//    @BindView(R.id.zhc_img)
//    AppCompatImageView zhcImg;
//    @BindView(R.id.zhc_txt)
//    AppCompatTextView zhcTxt;
//    @BindView(R.id.zhc_pro_bar)
//    ProgressBar zhcProBar;
//    @BindView(R.id.zhc_price)
//    AppCompatTextView zhcPrice;
//    @BindView(R.id.zhc_pro_txt)
//    AppCompatTextView zhcProTxt;
//    @BindView(R.id.zhc_txt2)
//    TextView zhcTxt2;
//    @BindView(R.id.order_info_block3)
//    LinearLayoutCompat orderInfoBlock3;
//
//    public PinTAdapter(int layoutResId, @Nullable List<ZhongChouResponse.ObjectBean.ListBean> data) {
//        super(R.layout.zhong_chou_item, data);
//    }
//
//    @Override
//    protected void convert(BaseViewHolder helper, ZhongChouResponse.ObjectBean.ListBean item) {
//
//        ToolsKit.setImg(item.getF_url(), zhcImg);
//        zhcTxt.setText(item.getCf_description());
//        List<ZhongChouResponse.ObjectBean.ListBean.LevelsBean> levels = item.getLevels();
//        ZhongChouResponse.ObjectBean.ListBean.LevelsBean levelsBean = levels.get(0);
//        zhcPrice.setText("￥" + levelsBean.getCfl_amount());
//        double cf_target_amount = item.getCf_target_amount();//目标金额
//        double cf_now_amount = item.getCf_now_amount();//已筹金额
//        double cf_now_count = item.getCf_now_count();//参加人数
//        BigDecimal twoNumber = ToolsKit.getTwoNumber(cf_now_amount, cf_target_amount);
//        int jindu = twoNumber.intValue();
//        zhcProTxt.setText(jindu + "%");
//        zhcProBar.setProgress(jindu);
//        if (this.getData().size() == (helper.getAdapterPosition() + 1)) {
//            LogKit.E("aaaa ---->   ", "  " + helper.getAdapterPosition());
//            ToolsKit.addMargin(helper.itemView, 0, 0, 0, SizeUtils.dp2px(20));
//        }
//    }

}